<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,1,2,2,3,3]
        var s = new Set([...arr])
        console.log(...s)
        new Promise((res,rej) => {
           setTimeout(() => {
            var a = false
            if (a) {
                res('888')
            } else {
                rej(666)
            }
           },1000)
        }).then((val) => {
            console.log(val)
        }).catch(e => {
            console.log(e)
        })
    function fn(){
       return new Promise((res,rej)=>{
            var xhr = new XMLHttpRequest()  
            xhr.open('get','https://liu.zzgoodqc.cn/teas')
            xhr.send()
            xhr.responseType = 'json'
            xhr.onload=()=>{
                res(xhr.response)
            }
            xhr.onerror = (e) =>{
                rej(e)
            }
        })
        
    }
        fn().then((val) => {
            console.log(val)
        }).catch(e => {
            console.log(e)
        })

    function fu(){
       return new Promise((res,rej)=>{
            var xhr = new XMLHttpRequest()  
            xhr.open('post','https://liu.zzgoodqc.cn/teas')
            xhr.send()
            xhr.responseType = 'json'
            xhr.onload=()=>{
                res(xhr.response)
            }
            xhr.onerror = (e) =>{
                rej(e)
            }
        })
    }
    fu().then((val) => {
            console.log(val)
        }).catch(e => {
            console.log(e)
        })

   function fu(){
       return new Promise((res,rej)=>{
            var xhr = new XMLHttpRequest()  
            xhr.open('delete','https://liu.zzgoodqc.cn/teas')
            xhr.send()
            xhr.responseType = 'json'
            xhr.onload=()=>{
                res(xhr.response)
            }
            xhr.onerror = (e) =>{
                rej(e)
            }
        })
    }
    fu().then((val) => {
            console.log(val)
        }).catch(e => {
            console.log(e)
        })
    function one(){
        
    }

    function fn1(){
    new Promise((res,rej) => {
           setTimeout(() => {
            var a = false
            if (a) {
                res('成功')
            } else {
                rej('失败')
            }
           },500)
        }) 
   }
   function fn2(){
    new Promise((res,rej) => {
           setTimeout(() => {
            var a = false
            if (a) {
                res('成功')
            } else {
                rej('失败')
            }
           },900)
        }) 
   }
   function fn3(){
    new Promise((res,rej) => {
           setTimeout(() => {
            var a = false
            if (a) {
                res('成功')
            } else {
                rej('失败')
            }
           },1000)
        }) 
   }
   Promise.all([fn1(), fn2(), fn3()])
      .then(val => {
        console.log(val)
      })
      .catch(e => {
        console.log(e)
      })
    Promise.any([fn1(), fn2(), fn3()])
    .then(val => {
        console.log(val)
      })
      .catch(e => {
        console.log(e)
      })
      Promise.race([fn1(), fn2(), fn3()])
    .then(val => {
        console.log(val)
      })
      .catch(e => {
        console.log(e)
      })
    </script>
</body>
</html>